﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Craft_List : MonoBehaviour
{
    public static Craft_List _instance;
    public Transform Craft_Entry_Prefabs;
    public Transform Scroll_Content;

    private void Awake()
    {
        _instance = this;
    }
    // Start is called before the first frame update
    void Start()
    {
        // 获得全部字典的信息
        List<CraftTable> craft_table = CraftTableInfo._instance.CraftTable_dic;
        foreach(CraftTable one_entry in craft_table)
        {
            Transform cell = Instantiate(Craft_Entry_Prefabs, Scroll_Content);
            CraftCellView cellinfo = cell.GetComponent<CraftCellView>();
            cellinfo.SetData(one_entry);
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    // 更新合成表的所有合成项目
    public void Refresh_Craft_Table()
    {
        CraftCellView[] cell_views = transform.GetComponentsInChildren<CraftCellView>();
        for(int i = 0; i < cell_views.Length; i++)
        {
            cell_views[i].Check_if_satisfied();
        }
    }
}
